package com.example.activity;

import android.content.ComponentName;
import android.content.Intent;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity3 extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        findViewById(R.id.bt3_back).setOnClickListener(this);
        findViewById(R.id.bt3_go).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.bt3_go) {
            /*// 1.构造方法指定目标activity
            Intent intent = new Intent(this, MainActivity4.class);*/

            /*// 2.setClass方法指定目标activity
            Intent intent = new Intent();
            intent.setClass(this, MainActivity4.class);*/

            // 3.setComponent方法指定目标activity
            Intent intent = new Intent();
            ComponentName componentName = new ComponentName(this, MainActivity4.class);
            intent.setComponent(componentName);
            startActivity(intent);
        }

        if (v.getId() == R.id.bt3_back)
            finish();
    }
}
